﻿using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Application.CustomMapper
{
    public class BaseMapper
    {
        /// <summary>
        /// 单字段映射
        /// </summary>
        /// <typeparam name="o">源对象</typeparam>
        /// <returns></returns>
        public static T Adapt<T>(Object o)
        {
            return o.Adapt<T>();
        }


        /// <summary>
        /// 列表映射
        /// </summary>
        /// <typeparam name="S">源类型</typeparam>
        /// <typeparam name="T">目标类型</typeparam>
        /// <param name="ss">源类型列表</param>
        /// <returns></returns>
        public static IEnumerable<T> Adapts<S, T>(IEnumerable<S> ss)
        {
            foreach (var x in ss)
            {
                yield return x.Adapt<T>();
            }
        }

    }
}
